<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<link rel="stylesheet" type="text/css" href="asset/css/reset.css">
	<link rel="stylesheet" type="text/css" href="asset/css/font-awesome-4.4.0/css/font-awesome.min.css">
	<link rel="stylesheet" type="text/css" href="asset/plugin/wangEditor/css/wangEditor.css">
	<link rel="stylesheet" type="text/css" href="asset/plugin/bootstrap/css/bootstrap.css">
	<link rel="stylesheet" type="text/css" href="asset/plugin/wangEditor/css/custom.css">
	<link rel="stylesheet" type="text/css" href="asset/plugin/wangEditor/css/app.css"/>
	<link rel="stylesheet" href="asset/plugin/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
	
	<link rel="stylesheet" type="text/css" href="asset/plugin/zui/css/zui.min.css"/>
	<link rel="stylesheet" type="text/css" href="asset/plugin/zui/css/chosen.css"/>
</head>
<body>

<div id="twEditor" style="padding:20px;">
	<div id="weWrap">
		<textarea id="report-source" style="width:90%; height: 400px;">
			<h1 style="text-align: center; ">南京市2014年国民经济和社会发展统计公报</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2014年，全市上下在市委、市政府的正确领导下，坚持稳中求进工作总基调，奋力书写“经济发展稳中向好、改革创新实现突破、青奥盛会精彩圆满”的“三份答卷”，统筹推进稳增长、促改革、调结构、重生态、惠民生各项工作，经济社会发展在新常态下呈现“稳中向好、转中提质”的良好态势。</p><h4>一、综合</h4><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;经济平稳增长。全年实现地区生产总值8820.75亿元，按可比价格计算，比上年增长10.1%。其中，第一产业增加值223.96亿元，增长3.5%；第二产业增加值3671.45亿元，增长8.8%，其中全部工业增加值3165.78亿元，增长9.3%；第三产业增加值4925.34亿元，增长11.5%。按常住人口计算，全市人均地区生产总值达到107545元，按年平均汇率折合17507美元。</p><p><br></p>
		</textarea>
	</div>
</div>
<p style="text-align: center">
	<button id="btnSave" class="btn btn-primary">保存</button>
</p>
	
	<script type="text/javascript" src="asset/js/jquery.js"></script>
	<script type="text/javascript" src="asset/plugin/wangEditor/js/wangEditor.js"></script>
	<script type="text/javascript" src="asset/plugin/layer/layer.js"></script>
	<script type="text/javascript" src="asset/plugin/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="asset/plugin/zTree/js/jquery.ztree.core.js"></script>
	<script type="text/javascript" src="asset/plugin/jQuery-slimScroll/jquery.slimscroll.min.js"></script>
	
	<!--<script src="asset/plugin/zui/js/zui.js" type="text/javascript" charset="utf-8"></script>-->
	
	<script type="text/javascript" src="asset/js/app.chart.min.js"></script>
	
	<script type="text/javascript"  src="asset/plugin/slide/2.1.1/slide.js"></script>
	<script src="asset/plugin/zui/js/chosen.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript" src="asset/plugin/echarts/echarts-all.js"></script>
	<script type="text/javascript" src="asset/plugin/wangEditor/tags-menu.js"></script>
	<script type="text/javascript" src="asset/plugin/wangEditor/chart-menu.js"></script>
	<!--<script type="text/javascript" src="asset/plugin/wangEditor/tags-menu-dev.js"></script><!--开发版-->-->
	<!--<script type="text/javascript" src="asset/plugin/wangEditor/chart-menu-dev.js"></script>-->
	<script type="text/javascript" src="asset/plugin/jquery-ui-1.10.4.min.js"></script>
	<!--<script type="text/javascript">
		$(document).ready(function() {
			$('.mydraggable').draggable({
			    connectToSortable: ".mysortable",
			    helper: "clone",
			    revert: "invalid",
			});

			$(".mysortable").sortable({
			    placeholder: "highlight_me",
			    cursor: "move",
			    handle: ".myhandler",
			    revert: true,
			    update: function (event, ui) {
			        $(ui.item).addClass('ui-sortable');
			        $(this).sortable("refresh");
			    }
			});
		});	
	</script>-->
	<script type="text/javascript">
	var json = {
    "type": "FeatureCollection",
    "features": [
        {
            "id": "320600",
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    "@@RFjJJEF[EIgEXMNAXAMAetUÜ¡ĮfGÄK\\GrS^OZSPW`ÅLÇHaNQHkPYD[CcO]EaNkPcZA@j[¢UƖ­FEJ_JMìßR_LWHu^PYÝhNMFUE_FJ¯ƁđnÓpSCIDA@_NQFC@AIMDAD[H[L[VC@QLAFUFCBWDaXU@UFYBQDSJ]JSVU`LDIRKHip_TtMFKBO@UCSCaIoUaKqWg]}ycFq^_Lď@uHaNqM^¥ĎYTQdUJSA·M¥UUA[@gJiFXJPBHURDF@NUJS@KFEFEHC\\EXuPIHbKHWBJW@@AC@[DI@@PCJGPE@GhFF@LLDFBBTDDPZBJ@FHBBDCTIVEDIAKJEHAND@DDGTBNDHDD@tZJBBGNOPAXMH@HFFBBBFFHLFENKFBB@RG@KEKAQII@KCCCAEG@ILEJEAECG@KHCLFFDHK\\@JGbBTCJGFEjBDCHBNCBK^CFGBABBLTBDDCHEDBLCBFjFV@FCFKVDBBDGJ@BDHGT@L@DGJE@GEOCEGMCGGCAGBILIBGDAFABCJABDFDBNC@FGDBPFJ@JFFD@BLF@BPALNDBB@FCFC@ADBdRDbDrAJDXNd\\LFHE@CJDBADEJ@BFAFRDRCRDPATLFBJEDBLCEaFADEdDDIDC@EHCZAJ{JIA@DE@SF@RBN@NBHAFCBDHDHALKNAA^RDD@LINAbARCLHR@DATDFCJ@XJDHPLJGFENEBGEA@APKBCKeACDGH@BF@HFDBDHJFAB@BGDAF@D@BDDAZSCIBGIECKJGCODCJAHBBFLNDH@FTNZLNDJBF@FERABQR@B@DKP@ATDFªFBOC]ZH^TZJJTP@JCJ@^LABICMDIIA@@VZDAVBLF"
                ],
                "encodeOffsets": [
                    [
                        123810,
                        33423
                    ]
                ]
            },
            "properties": {
                "cp": [
                    120.864608,
                    32.016212
                ],
                "name": "南通市",
                "childNum": 1
            }
        }
        ],
    "UTF8Encoding": true
}

	function decode(json) {
        if (!json.UTF8Encoding) {
            return json;
        }
        var features = json.features;

        for (var f = 0; f < features.length; f++) {
            var feature = features[f];
            var geometry = feature.geometry;
            var coordinates = geometry.coordinates;
            var encodeOffsets = geometry.encodeOffsets;

            for (var c = 0; c < coordinates.length; c++) {
                var coordinate = coordinates[c];

                if (geometry.type === 'Polygon') {
                    coordinates[c] = decodePolygon(
                        coordinate,
                        encodeOffsets[c]
                    );
                }
                else if (geometry.type === 'MultiPolygon') {
                    for (var c2 = 0; c2 < coordinate.length; c2++) {
                        var polygon = coordinate[c2];
                        coordinate[c2] = decodePolygon(
                            polygon,
                            encodeOffsets[c][c2]
                        );
                    }
                }
            }
        }
        // Has been decoded
        json.UTF8Encoding = false;
        return json;
        console.log(JSON.stringify(json));
    }

    function decodePolygon(coordinate, encodeOffsets) {
        var result = [];
        var prevX = encodeOffsets[0];
        var prevY = encodeOffsets[1];

        for (var i = 0; i < coordinate.length; i += 2) {
            var x = coordinate.charCodeAt(i) - 64;
            var y = coordinate.charCodeAt(i + 1) - 64;
            // ZigZag decoding
            x = (x >> 1) ^ (-(x & 1));
            y = (y >> 1) ^ (-(y & 1));
            // Delta deocding
            x += prevX;
            y += prevY;

            prevX = x;
            prevY = y;
            // Dequantize
            result.push([x / 1024, y / 1024]);
        }

        return result;
        // console.log(result);
        console.log(JSON.stringify(result));
    }



	$(document).ready(function() {
		var editor = new wangEditor('report-source');
		editor.config.menus = [
			'source',
	        '|',
	        'bold',
	        'underline',
	        'italic',
	        'strikethrough',
	        'eraser',
	        'forecolor',
	        'bgcolor',
	        '|',
	        'quote',
	        'fontfamily',
	        'fontsize',
	        'head',
	        'unorderlist',
	        'orderlist',
	        'alignleft',
	        'aligncenter',
	        'alignright',
	        '|',
	        'link',
	        'unlink',
	        'table',
	        // 'emotion',
	        '|',
	        'img',
	        'video',
	        // 'location',
	        'tags',
	        'chart',
	        '|',
	        'undo',
	        'redo',
	        'fullscreen'

	        // 'source',
	        // '|',
	        // 'bold',
	        // 'lineheight',
	        // 'tag',
	        // 'chart',
	        // 通过自定义菜单，让新配置的菜单显示在页面中。
	        // 上文已经确定，新配置的『缩进』菜单id为 'indent'
	        // 'indent'
	    ];
		editor.create();

		// var GetUrl = 'http://192.168.0.25:5010';
		// var _options=ChartParser.options();
		// editor.$txt.find(".charts").each(function(index){
		// 	var $chart = $(this);

		// 	var chartarrO = $.trim($chart.find(".chartjson").html());
		// 	var chartarr =  chartarrO.slice(13,chartarrO.length-4);

	 //        $.ajax({
	 //            type:"POST",
	 //            data:chartarr,
	 //            dataType:"jsonp",
	 //            jsonp:"callback",
	 //            url:GetUrl + "/TrueDPS/formulaController/getResult.do?function="+chartarr,
	 //            success:function(msg){
	 //                var val;
	 //                if(msg.success){
	 //                    val = msg.data;
	 //                    // console.log(val)
	 //                    console.log(JSON.stringify(val));
	 //                    var dd = val;

	 //                    var opGroupO = $.trim($chart.find(".chartoptiongroup").html());
		// 				var opGroup =  JSON.parse(opGroupO.slice(13,opGroupO.length-4));

		// 				var cdata=parseData(dd,opGroup);

		// 				var chartId = $chart.find('.chart-box').attr("id");
		// 				var chartItem = echarts.init(document.getElementById(chartId))
		// 	            chartItem.setOption(cdata);


	 //                }else{
	 //                    val = msg.error;
	 //                }

	                       
	 //            }
	 //        });



			

		// })

		// 处理图表数据
			function parseData(data,group){
			    var option=_options[group.type];
			    var cdata={};
			    option.base.forEach(function(e){
			        if(!!group[e]){
			            var d=getCells(data,group[e],e);
			            cdata[e]={direction:d[0],value:d[1]};
			        }
			    }); 
			    var parse=ChartParser[group.type];
			    if(typeof parse==='function'){
			        return parse(cdata);
			    }
			    return null;
			}

			function getCells(data,sels,type){
			    var values=[];
			    var direction='',ld=0,cd=0;
			    var r=sels[0],c=sels[1],lr=sels[2],lc=sels[3];
			    for(;r<=lr;r++){
			        for(var _c=c;_c<=lc;_c++){
			            var d=data[r][_c];
			            if(d==null){
			                if(type=='value'){
			                    values.push({r:r,c:_c,value:null});
			                }
			            }else{
			                values.push({r:r,c:_c,value:d});
			            }
			        }
			    }
			    if(lr-r<lc-c){
			        direction='left-right';
			    }else if(lr-r>lc-c){
			        direction='top-bottom';
			    }else{
			        direction='';
			    }
			    return [direction, values];
			}

		$("#btnSave").click(function(){
			var tags = editor.$txt.find('.tags');
			
			 
			$("#tagTem textarea").each(function(){
			 	var id = $(this).attr("id");
			 	var tagV = $(this).val();
			 	tags.each(function(){
			 		var tid = $(this).attr('data-id');
			 		var tem = $(this).text();
			 		if(id == tid){
			 			$(this).html('<i class="tagtmp">'+tem+'</i><!--TrueDATA['+tagV+']-->');
			 		}
			 	})
			})

			// var charts = editor.$txt.find('.charts');
			// charts.find('.chart-box').html('');

			var html = editor.$txt.html();


			console.log(html);
		})
	});
	</script>
</body>
</html>